{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-header">手动组卷</div>
    <div class="layui-card-body">
    <form action="{:request()->url()}" class="layui-form" method="post">
        <table class="layui-table layui-form">
            <thead>
            <tr>
                <th>试卷名称</th>
                <th style="width:160px;">试卷类型</th>
                <th style="width:160px;">科目分类</th>
                <th style="width:160px;">开考时间</th>
                <th style="width:100px;">考试时长</th>
                <th style="width:100px;">及格线占比</th>
            </tr>
            </thead>
            <tbody>
                <tr>
                    <td><input type="text" name="exam" lay-verify="required"  placeholder="必填" class="layui-input"></td>
                    <td><div class="layui-input-inline">
                            <input type="radio" name="examtype" value="1" title="练习" checked>
                            <input type="radio" name="examtype" value="2" title="考试">
                        </div>
                    </td>
                    <td><select name="examsubject" lay-verify="required" lay-filter="selectedsubjectid" id="selectedsubjectid">
                            <option value="">全部分类</option>
                            {foreach name="courseCategory" item="v"}
                            <option value="{$v.id}">{$v.cname}</option>
                            {/foreach}
                         </select>
                    </td>
                    <td><input type="text" id="starttime" name="starttime"  placeholder="为空即为不定时开始" class="layui-input"></td>
                    <td><input type="text" name="examtime" lay-verify="required|Ndouble" placeholder="单位：分钟" class="layui-input"></td>
                    <td><input type="text" name="passscore" lay-verify="required" placeholder="大于0，小于1" class="layui-input"></td>
                </tr>
            </tbody>
        </table>
        <table class="layui-table layui-form mt20" lay-skin="nob">
            <thead>
                <tr>
                    <th style="width:140px;">题型</th>
                    <th style="width:80px;">题数</th>
                    <th style="width:80px;">单题分值</th>
                    <th style="width:80px;">已选	</th>
                    <th style="width:150px;">操作</th>
                    <th>试题说明</th>
                </tr>
            </thead>
            <tbody>
                {foreach name="questiontype" item="v"}
                <tr>
                    <td>{$v.type_name}</td>
                    <td><input type="text" name="questype[{$v.id}][number]"  readonly=”readonly” class="layui-input"  id="iselectallnumber_{$v.id}"></td>
                    <td><input type="text" name="questype[{$v.id}][score]"   class="layui-input questypescore" id="iselectallscore_{$v.id}"></td>
                    <td><span id="ialreadyselectnumber_{$v.id}">0</span></td>
                    <td><a  href="{:url('admin/exam/questionsSelect',['questiontype'=>$v.id])}" class="layui-btn layui-btn-sm ajax-iframe_noshut select" data-width="800px" data-height="500px">选题</a></td>
                    <td><input type="text" name=questype[{$v.id}][describe] id="describe_{$v.id}"   value="每小题？分，本题共？个小题，共？分" class="layui-input"></td>
                    <input type="hidden" value="" id="iselectquestions_{$v.id}" name="examquestions[{$v.id}][questions]" />
                </tr>
                {/foreach}

            </tbody>
        </table>
        <div class="layui-form-item mt20">
            <div class="layui-input-block">
                <button class="layui-btn" lay-filter="*" lay-submit="">生成试卷</button>
                <button class="layui-btn layui-btn-primary" type="reset">重置</button>
            </div>
        </div>
        <input type="hidden" name="addtime" value="{$addtime}"  class="layui-input">
    </form>
    </div>
</div>
{/block}
{block name="js"}
<script>
    var scoreArry=[];
    form.on('select(selectedsubjectid)', function(data){
        var subjectid=data.value;
        var url='/api/author/ajaxsetsession';
        $.ajax({
            url: url,
            type: 'post',
            dataType: 'json',
            data: {name:'subjectid',value:subjectid},
            success: function (result) {
            }
        });
    });
    $('.questypescore').on('blur', function () {
        var name=$(this).attr('id');
        var idArry=  name.split("_");
        var questypenumber=$('#iselectallnumber_'+idArry[1]).val();
        if(questypenumber==''){
            $(this).val('');
            layer.msg('请先选择试题');
        }
        var questypescore=$(this).val();
        var score=parseFloat(questypescore)*parseInt(questypenumber);
        var html='每小题'+questypescore+'分，本题共'+questypenumber+'个小题，共'+score+'分';
        $('#describe_'+idArry[1]).val(html);
    });
    laydate.render({
        elem: '#starttime'
        ,type: 'datetime'
        ,trigger: 'click'
    });
</script>
{/block}


